package GUIPanels;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JPanel;

import World.World;


public class PeoplePanel extends JPanel {
	public PeoplePanel() {
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	Font labelTxt = new Font("TimesRoman",Font.BOLD,14);
	
	public void paintComponent(Graphics g)
	{
		//super.paintComponent(g);
		int cellSize = World.cellSize; //Main.myWorld.cellSize;
		this.setOpaque(false);
		//this.setBackground(Color.red);
		this.removeAll();

		//System.out.println("--------- YEAR "+ World.pop.getYear() +" -----------");
		System.out.println(World.pop.Report());
		for (int i=0; i<World.pop.getLength(); i++)
		{
			System.out.println(i+"_"+ World.pop.get(i).isAlive +": "+World.pop.get(i).getX() + "," + World.pop.get(i).getY() + "  ID:" + World.pop.get(i).getID() + "  Age:" + World.pop.get(i).getAge()+ "   Friends:"+World.pop.get(i).getFriends().ReportFriends()+"  Assoc:"+World.pop.get(i).getAssociatedFriends().ReportFriends());
			if(World.PrintToOutFile)
				World.outFile.println(i+"_"+ World.pop.get(i).isAlive +": "+World.pop.get(i).getX() + "," + World.pop.get(i).getY() + "  ID:" + World.pop.get(i).getID() + "  Age:" + World.pop.get(i).getAge()+ "   Friends:"+World.pop.get(i).getFriends().ReportFriends()+"  Assoc:"+World.pop.get(i).getAssociatedFriends().ReportFriends());
			g.setColor(World.pop.get(i).getColor());
			//g.clipRect((int)World.population[i].getX()*cellSize+(int)(0.25*cellSize), (int)World.population[i].getY()*cellSize+(int)(0.25 * cellSize), 1+(int)(0.5*cellSize),1+(int)(0.5*cellSize));
			g.fillRect((int)World.pop.get(i).getX()*cellSize+(int)(0.25*cellSize), (int)World.pop.get(i).getY()*cellSize+(int)(0.25 * cellSize), 1+(int)(0.5*cellSize),1+(int)(0.5*cellSize));
			
			g.setFont(labelTxt);
			g.setColor(Color.blue);
			g.drawString(""+World.pop.get(i).getID(),(int)World.pop.get(i).getX()*cellSize+(int)(0.25*cellSize), (int)World.pop.get(i).getY()*cellSize+(int)(0.25 * cellSize));
		}
		
		for(int j=0; j<World.pop.groups.length; j++){
			System.out.println(World.pop.groups[j].ReportGroup());
		}
	}
}
